package org.inasnet.frame;

import java.util.Calendar;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;

import javax.swing.JFrame;
import javax.swing.JTextArea;


/**
 * Class for logging output information.
 */
public class DebugFrame extends JFrame
{
	public DebugFrame()
	{
	}

	public void log( String message )
	{
		SimpleDateFormat dataFormat = new SimpleDateFormat( mTimeFormat );
		
		String post = dataFormat.format( Calendar.getInstance().getTime() ) + " " + message;
		
		//mMessageTrace.setText( mMessageTrace.getText() + post );
		
		System.out.println( post );
	}
	
	class Output extends OutputStream
	{
		Output()
		{
			System.setOut( new PrintStream( this ) );
		}

		public void write( int b ) throws IOException 
		{
			System.out.print( b );
			
			mMessageTrace.append( "" + b );
		}
	}
	
	//Output mOutput = new Output();
	
	JTextArea mMessageTrace;
	
	final String mTimeFormat = "HH:mm:ss";
}
